﻿using System;
using System.Collections;
using UnityEngine;
namespace FrameWorkSong
{
    public partial class MonoBehaviourSimplify : MonoBehaviour
    {
        /// <summary>
        /// 清理缓存
        /// </summary>
        protected void ReleaseMemory()
        {
            Resources.UnloadUnusedAssets();
            GC.Collect();
        }
        protected string GetNowTime()
        {
            return DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
        }
        /// <summary>
        /// 延时功能
        /// </summary>
        /// <param name="seconds">延迟时间</param>
        /// <param name="onFinished">调用方法</param>
        public void Delay(float seconds, Action onFinished)
        {
            StartCoroutine(DelayCoroutione(seconds, onFinished));
        }
        private IEnumerator DelayCoroutione(float seconds, Action onFinished)
        {
            yield return new WaitForSeconds(seconds);
            onFinished();
        }
    }
}
